package com.fz.us.oa.core.entity.com;

import com.fz.us.admin.company.entity.BaseFlowEntity;
import com.fz.us.admin.company.entity.Department;
import com.fz.us.admin.company.entity.User;
import com.fz.us.admin.dict.entity.DictItem;
import com.fz.us.oa.core.entity.common.FileManage;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 业务实体类 - 公告通知登记表
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author XuHeng
 * @version 1.0 2016-12-28 。
 * ============================================================================
 */
@Entity
@Table(name="ec_notice")
public class Notice extends BaseFlowEntity {

    private static final long serialVersionUID = 2643922047075176759L;
    /**
     * 通知主题
     */
    private String subject;
    /**
     * 是否置顶 1:是 0:否
     */
    private int isTop;

    /**
     * 公告类型字典项
     */
    private DictItem dictItem;

    /**
     * 发布部门
     */
    private Department issueDepartment;

    /**
     * 通知对象 0:全体员工（默认全体员工）  1:部门    2:个人
     */
    private int noticeType;

    /**
     * 部门
     */
    private Set<Department> noticeDepartments;

    /**
     * 通知个人
     */
    private Set<User> noticeUsers;

    /**
     * 内容
     */
    private String content;

    /**
     * 附件
     */
    private List<FileManage> file;

    /**
     * 提交日期
     */
    private Date dateApply;
    /**
     * 文档状态数值
     */
    private int numStatus;
    /**
     * 文档状态文字
     */
    private String txtStatus;

    /**
     * 表单名称
     */
    private String form;

    @Column(nullable=false, columnDefinition = "varchar(50) default '公告通知登记表'")
    public String getForm() {
        return form;
    }

    public void setForm(String form) {
        this.form = form;
    }

    public int getIsTop() {
        return isTop;
    }

    public void setIsTop(int isTop) {
        this.isTop = isTop;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public DictItem getDictItem() {
        return dictItem;
    }

    public void setDictItem(DictItem dictItem) {
        this.dictItem = dictItem;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Department getIssueDepartment() {
        return issueDepartment;
    }

    public void setIssueDepartment(Department issueDepartment) {
        this.issueDepartment = issueDepartment;
    }

    public int getNoticeType() {
        return noticeType;
    }

    public void setNoticeType(int noticeType) {
        this.noticeType = noticeType;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @OrderBy("pinYinHead asc")
    public Set<Department> getNoticeDepartments() {
        return noticeDepartments;
    }

    public void setNoticeDepartments(Set<Department> noticeDepartments) {
        this.noticeDepartments = noticeDepartments;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @OrderBy("pinYinHead asc")
    public Set<User> getNoticeUsers() {
        return noticeUsers;
    }

    public void setNoticeUsers(Set<User> noticeUsers) {
        this.noticeUsers = noticeUsers;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_notice_file", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="fileId"))
    public List<FileManage> getFile() {
        return file;
    }

    public void setFile(List<FileManage> file) {
        this.file = file;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Date getDateApply() {
        return dateApply;
    }

    public void setDateApply(Date dateApply) {
        this.dateApply = dateApply;
    }

    public int getNumStatus() {
        return numStatus;
    }

    public void setNumStatus(int numStatus) {
        this.numStatus = numStatus;
    }

    public String getTxtStatus() {
        return txtStatus;
    }

    public void setTxtStatus(String txtStatus) {
        this.txtStatus = txtStatus;
    }
}
